// Copyright (c) 2024, the WwMusic project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

package com.springfairy.controller;

import com.springfairy.model.MoodPointImages;
import com.springfairy.service.MoodPointImageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;



@RestController
@RequestMapping("/images")
public class MoodPointImageController {
    @Autowired
    private MoodPointImageService service;

    @PostMapping("/create")
    public ResponseEntity<MoodPointImages> addMoodPointImages(@RequestParam Integer pointId, @RequestParam String url) {
        return ResponseEntity.ok(service.uploadImage(pointId,url));
    }

    @PostMapping("/list")
    public ResponseEntity<List<MoodPointImages>> getAllPointImages(@RequestParam Integer pointId) {
        return ResponseEntity.ok(service.getImagesByPoint(pointId));
    }

    public ResponseEntity<Boolean> deletePointImages(Integer id) {
        return ResponseEntity.ok(service.deleteImage(id));
    }
}
